package com.work.cloudseata.common;

import lombok.Data;

@Data
public class Ret<T> {

    private Integer code;

    private String msg;

    private T data;

    public static <T> Ret<T> ok() {
        return create(0, "成功", null);
    }

    public static <T> Ret<T> ok(T data) {
        return create(0, "成功", data);
    }

    public static <T> Ret<T> fail(String msg) {
        return fail(500, msg);
    }

    public static <T> Ret<T> fail(Integer code, String msg) {
        return create(code, msg, null);
    }

    public static <T> Ret<T> create(Integer code, String msg, T data) {
        Ret<T> ret = new Ret<>();
        ret.setCode(code);
        ret.setMsg(msg);
        ret.setData(data);
        return ret;
    }
}
